package com.he.heblog.config.mvcConfig;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

/*视图控制器，使请求不经过控制器，直接访问视图页面，*/
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("index").setViewName("front/user/userIndex");
        registry.addViewController("register").setViewName("front/register");
        registry.addViewController("text").setViewName("/front/text");
//        springsecurity登录页面是get请求，而登录失败请求转发回登录页面发送的是post请求
        registry.addViewController("login.html").setViewName("login");
        WebMvcConfigurer.super.addViewControllers(registry);
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }
}
